home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / compuserve-file-archive / 03 Demos and Info / SEQIO.TXT < prev    next >
Encoding:
Text File  |  2019-04-13  |  3.1 KB  |  109 lines

  1.  
  2.  
  3.  #: 58923      Sub-topic 3 - Disk Programming
  4. Sb: #58585-#PROGRAMMING C-64
  5.     03-Feb-85  15:13:41
  6. Fm: Ken Kehl   70616,226
  7. To: Ken Hurt   74546,303
  8.  
  9.  
  10.   Ken, printing information to SEQ files is just like printing to the screen
  11. with a few small changes.
  12.  
  13.   First the file must be opened.
  14.  
  15.   10 open1,8,3,"0:seqfile,s,w"
  16. (the ,s,w means sequential,write. If you only want to read the file, this can
  17. be left off, as the DOS assumes ,s,r if no type & direction are given.)
  18.  
  19.  then print the information to the file. (print means output, and the screen
  20. just happens to be the default output device, that's all)
  21.  
  22.   20 print#1,"this is a textfile"
  23.  
  24.   then the file should be closed up.
  25.  
  26.   30 close 1
  27.  
  28.   If you are using a string as a filename, you just concatenate the name to
  29. match proper syntax
  30.  
  31.   5 input"filename";f$:iff$=""goto5
  32.   10 open1,8,3,"0:"+f$+",s,w"
  33.  
  34.  continued in reply...enter rr
  35.  
  36. * Reply:
  37.     58924
  38. (UA RE T): 
  39.  
  40.  #: 58924      Sub-topic 3 - Disk Programming
  41. Sb: #58923-#PROGRAMMING C-64
  42.     03-Feb-85  15:15:22
  43. Fm: Ken Kehl   70616,226
  44. To: Ken Kehl   70616,226 (X)
  45.  
  46.  
  47.   You can also print strings to the file from memory (which is what you ar    really asking about I think)
  48.  
  49.  5 fort=1to10:a$(t)="file"+str$(t):next
  50.  6 open1,8,3,"0:filename,s,w"
  51.  7 fort=1to10:print#1,a$(t);:next
  52.  8 close1
  53.  
  54.  Just like the screen, if you don't put a semicolon after each print#, a
  55. carriage return chr$(13) is put in the file at the next print# statement. If
  56. you are retrieving information which is to be put on the screen, this can be
  57. handy, as the proper carriage returns can be built into the file.
  58.  
  59.  Don't forget that print# isn't abbreviated as ?# but as p shift R.
  60.  
  61.        clarify all of this, it might help to experiment by using the screen as a
  62. non-default output device.
  63.  
  64.   10 open1,3:rem device 3=screen
  65.   20 print#1,"text"
  66.   30 close1
  67.  
  68.   continued in reply...
  69.  
  70. * Reply:
  71.     58925
  72. * RR 58923 +
  73. (UA RE T): 
  74.  
  75.  #: 58925      Sub-topic 3 - Disk Programming
  76. Sb: #58924-PROGRAMMING C-64
  77.     03-Feb-85  15:17:39
  78. Fm: Ken Kehl   70616,226
  79. To: Ken Kehl   70616,226 (X)
  80.  
  81.  
  82.   Information can be retrieved from the SEQ file with either GET# or INPUT#
  83. commands. If there is a possibility that the    ile may contain a null string
  84. -chr$(0)- you will have to allow for this before performing any operations on
  85. the string. using the statement a$=a$+cH(0) will relace the null string with a
  86. chr$(0) and allow operations like print asc(a$) without errors.
  87.  
  88.   GET# receives info one byte at a time, while INPUT# will gather strings until
  89. it comes across a terminator like a comma, or a carriage return (a chr$(0)
  90. might cause problems here, and you should test for input of null strings -
  91. ifa$=""then whatever...)
  92.   Y     can close a file as many times as you want, but if you try to retrieve
  93. data from an unopened file, you will get an error.
  94.  
  95.   Here's a simple SEQ file reader.
  96.  10 open1,8,3,"0:filename"
  97.  20 get#1,a$:printa$;:ifst=0then20
  98.  30 close1
  99.  
  100.  When the last byte of a file is read, the value of ST (the status variable)
  101. becomes non zero, and the program ends.
  102.  You will have to ask someone else about relative files.
  103.  
  104.    WHEW! That should get you started.
  105.  
  106.                             Ken
  107.  
  108. * RR 58923
  109. (UA RE T):